package com.mercury.pattern._15_iterator;

import java.util.Iterator;
import java.util.List;

/**
 *
 */
public class InfoIterator implements Iterator {

    List<Department> depts;

    int position = 0;

    public InfoIterator(List<Department> depts) {
        this.depts = depts;
    }

    @Override
    public boolean hasNext() {
        if(position >= depts.size()){
            return false;
        }
        return true;
    }

    @Override
    public Object next() {
        Department department = depts.get(position++);
        return department;
    }
}